package com.anmong.cloud.cloudcommon.config;

import com.anmong.cloud.cloudcommon.config.feign.FeignErrorDecoder;
import com.anmong.cloud.cloudcommon.config.feign.FeignResultDecoder;
import com.fasterxml.jackson.databind.ObjectMapper;
import feign.Logger;
import feign.Request;
import feign.codec.Decoder;
import feign.codec.ErrorDecoder;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DefaultFeignConfig {

    @Resource
    ObjectMapper objectMapper;

    @Bean
    public Logger.Level logLevel(){
        return Logger.Level.BASIC;
    }

    @Bean
    public Request.Options options() {
        return new Request.Options(5000, 5000);//可@Value配置
    }

    @Bean
    public Decoder feignDecoder() {
        return new FeignResultDecoder(objectMapper);
    }

    @Bean
    public ErrorDecoder errorDecoder() {
        return new FeignErrorDecoder();
    }


}
